﻿@helper LoggedInUser()
{   
    if (User != null && User.Identity != null && User.Identity.IsAuthenticated)
    { 
    @:Hello, @Html.ActionLink(User.Identity.Name ?? "Manage", "Manage", "Account")
    }
    else
    { 
    @Html.ActionLink("Register", "Register", "Account")
    }
}

@helper ActiveItem(string actionName, string controllerName, string areaName)
{
    if (ViewContext.RouteData.Values["action"].ToString() == actionName &&
            ViewContext.RouteData.Values["controller"].ToString() == controllerName &&
            (ViewContext.RouteData.DataTokens["area"] == null || ViewContext.RouteData.DataTokens["area"].ToString() == areaName))
    {
    @:active
    }
}

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="@Url.Action("Index", "Home")"><i class="fa fa-anchor fa-fw fa-lg" style="color:cornflowerblue"></i> ShippingProject</a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li class="@ActiveItem("Index", "Home", null)"><a href="@Url.Action("Index", "Home")"><i class="fa fa-home fa-fw fa-lg"></i></a></li>
                <li class="@ActiveItem("About", "Home", null)">@Html.ActionLink("About", "About", "Home")</li>
                <li class="@ActiveItem("Contact", "Home", null)">@Html.ActionLink("Contact", "Contact", "Home")</li>
                <li class="@ActiveItem("Index", "Contest", null)">@Html.ActionLink("Contests", "Index", "Contest")</li>
                @*@if (Request.IsAuthenticated)
                {
                    <li class="@ActiveItem("MyContests", "Contest", null)">@Html.ActionLink("My contests", "MyContests", "Contest")</li>
                }*@
            </ul>
            @if (Request.IsAuthenticated)
            {
                <ul class="nav navbar-nav pull-right">
                    <li>
                        <div class="nav navbar-text">@LoggedInUser()</div>
                    </li>
                    <li>
                        <div class="nav" style="margin-top: 4px; margin-bottom: 4px;">
                            @*<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>*@
                            @*@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, htmlAttributes: new { id = "logoutForm", @class = "navbar-form" }))
                            {
                                <button type="submit" class="btn-link"><i class="fa fa-sign-out fa-fw fa-lg"></i>Log off</button>
                                @Html.AntiForgeryToken()
                            }*@
                        </div>
                    </li>
                </ul>
            }
            else
            {
                <ul class="nav navbar-nav pull-right">
                    <li class="@ActiveItem("Register", "Account", null)">@Html.ActionLink("Register", "Register", "Account", null, new { data_toggle = "modal", data_target = "#regModal" })</li>
                    <li class="@ActiveItem("Login", "Account", null)">@Html.ActionLink("Login", "Login", "Account", null, new { data_toggle = "modal", data_target = "#authModal" })</li>
                </ul>
            }
        </div>
    </div>
</div>

<div class="modal fade" id="authModal" tabindex="-1" role="dialog" aria-labelledby="authLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">   
            <div class="modal-body">
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="regModal" tabindex="-1" role="dialog" aria-labelledby="regLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">   
            <div class="modal-body">
            </div>
        </div>
    </div>
</div>